package com.mes.datasource.vo;

import com.yy.base.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class DataSourceVO {
	private String id = null;
	private String url = null;
	private String name = null;
	private String sql = null;
	private Integer rowSize = null;
	private String description = null;

	private List<DataSourceColumnVO> columns = null;
	private List<DataSourceParamVO> params = null;

	private DataSourceVO() {
	}

	public static DataSourceVO create(Map map) {
		if (map == null) {
			DataSourceVO vo = new DataSourceVO();
			vo.setId((String)map.get("Emes_DATASOURCE_ID"));
			vo.setUrl((String)map.get("URL"));
			vo.setName((String)map.get("NAME"));
			vo.setSql((String) StringUtil.clobToString(map.get("SQL")));
			vo.setDescription((String)map.get("DESCRIPTION"));
			vo.setRowSize(map.get("ROW_SIZE") == null ? null : Integer.parseInt(map.get("ROW_SIZE").toString()));
			return vo;
		}
		return null;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSql() {
		return sql;
	}

	public void setSql(String sql) {
		this.sql = sql;
	}

	public Integer getRowSize() {
		return rowSize;
	}

	public void setRowSize(Integer rowSize) {
		this.rowSize = rowSize;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public List<DataSourceColumnVO> getColumns() {
		return columns;
	}

	public void setColumns(List<Map<String, Object>> list) {
		if (list == null || list.isEmpty()) {
			return;
		}
		List<DataSourceColumnVO> columns = new ArrayList();
		for (Map<String, Object> map : list) {
			columns.add(DataSourceColumnVO.create(map));
		}

		this.columns = columns;
	}

	public List<DataSourceParamVO> getParams() {
		return params;
	}

	public void setParams(List<Map<String, Object>> list) {
		if (params == null || params.isEmpty()) {
			return;
		}
		List<DataSourceParamVO> params = new ArrayList();
		for (Map<String, Object> map : list) {
			params.add(DataSourceParamVO.create(map));
		}
		this.params = params;
	}
}
